//自己的迭代方法
//将头节点单独处理
//官方是创建一个头节点
var removeElements = function(head, val) {
    if(head==null)return head
    let result
    while(head!==null){
        if(head.val == val){
            head = head.next
        }
        else{
            break;
        }
    }
    result = head
    if(head==null)return head
    while(head.next!==null){
        if(head.next.val==val){
            const res = head.next
            head.next = head.next.next
            res.next = null
        }else{
            head = head.next
        }
    }
    return result
};